<%
/**
 *      角色的地址本Frame
 *      含是否多选的参数
 *
 *  $Author: amon_lei $
 *  $Date: 2004/12/15 13:53:08 $
 *  $Revision: 1.4 $ 
 *  created in 2004-12-12
 */
%>
<%@ include file = "/common/ini.jsp"%>
<%@ include file = "/common/_log4j.jsp"%> 
<%@ include file = "/common/_ApplicationContext_init.jsp"%> 

<html>
        <%@ include file = "/tree_css_js_img/_xtree_css.jsp"%>
        <%@ include file = "/tree_css_js_img/_xtree_js.jsp"%>
        <%@ include file = "/common/AddressList/js/_AList_Frame_js_.jsp"%>
        <%@ include file = "_public_String_makeNoRootNodeView_Str_id_Str_name_Str_nodeType_Str_onclickJS_Str_superId_Str_openImg_Str_closeImg_.jsp"%>
        <%@ include file = "_public_String_makeRootNodeView_Str_id_name_Str_nodeType_Str_onclickJS_Str_openImg_Str_closeImg_Str_visibleImg.jsp"%>
<%
        //显示Role树图
        RoleManager roleManager = (RoleManager)applicationContext.getBean("roleManager");
        logger.info("开始构造地址本frame - role2role");
        Role rootRole = new Role();
        if( !request.getParameter("rootRoleCode").equals("null"))
        {
            logger.debug("根结点 != null");
            String rootRoleCode = request.getParameter("rootRoleCode");
            Role role = roleManager.getByCode(rootRoleCode);
            if(role == null)
            {
                logger.error("code为" + rootRoleCode + "的角色不存在");
                return;
            }
            rootRole.addRole(role);
        }
        else
        {
            logger.debug("根结点 == null");
            List roles = roleManager.findRoles(rootRole.getId());
            logger.debug("节点个数：" + roles.size());
            rootRole.addSubRoles(new LinkedHashSet(roles));
        }
        Object[] roles = rootRole.getAllSubRoles().toArray();
        
%>
        <script>  
                 <%
                        out.print(this.makeRootNodeView("ROLE",
                                                        rootRole.getId(),
                                                        WebPath + "/tree_css_js_img/images/root.gif")
                                 );
                        for(int i = 0; i < roles.length; i ++)
                        {
                            Role role = (Role)roles[i];
                            out.print(this.makeNoRootNodeView(role.getId(),
                                                              role.getName(),
                                                              "ROLE",
                                                              "select('" + role.getId() + "','" + role.getName() + "','ROLE')",
                                                              "ROLE",
                                                              role.getSuperRole().getId(),
                                                              WebPath + "/tree_css_js_img/images/role.gif",
                                                              WebPath + "/tree_css_js_img/images/role.gif")
                                     );
                        }
                        
                %>
                document.write(Node0);
        </script>
</html>
